import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

import Layout from '@/layout'

export const constantRoutes = [{
  path: '/redirect',
  component: Layout,
  hidden: true,
  children: [{
    path: '/redirect/:path(.*)',
    component: () =>
      import ('@/views/redirect/index')
  }]
},
{
  path: '/login',
  component: () =>
    import ('@/views/login/index'),
  hidden: true
},
{
  path: '/register',
  component: () =>
    import ('@/views/register/index'),
  hidden: true
},
{
  path: '/legalStatement',
  component: () =>
    import('@/views/info/legalStatement'),
  hidden: true
},
{
  path: '/userAgreement',
  component: () =>
    import('@/views/info/userAgreement'),
  hidden: true
},
{
  path: '/',
  component: Layout,
  redirect: '/dashboard',
  children: [{
    path: 'dashboard',
    component: () =>
      import ('@/views/dashboard/index'),
    name: '首页',
    meta: {
      title: '首页',
      icon: 'iconfont iconshouye',
      affix: true
    }
  },
  {
    path: 'dashboard/employList',
    component: () =>
      import ('@/views/dashboard/employList'),
    name: 'DashboardList',
    meta: {
      title: '录用日程',
      noCache: true,
      activeMenu: '/dashboard'
    },
    hidden: true
  },
  {
    path: 'dashboard/interviewList',
    component: () =>
      import ('@/views/dashboard/interviewList'),
    name: 'InterviewList',
    meta: {
      title: '面试日程',
      noCache: true,
      activeMenu: '/dashboard'
    },
    hidden: true
  }
  ]
},
{
  path: '/special-session',
  component: Layout,
  children: [{
    path: '/special-session',
    component: () =>
      import('@/views/special-session/index'),
    name: 'special-session',
    meta: {
      title: '专场招聘',
      icon: 'iconfont iconzhaopin',
      affix: true
    }
  },
  {
    path: 'details',
    name: 'specialSessionDetails',
    hidden: true,
    component: () =>
      import('@/views/special-session/components/details'),
    meta: {
      activeMenu: '/special-session'
    }
  }
  ]
},

{
  path: '/positionmanage',
  component: Layout,
  children: [{
    path: 'index',
    component: () =>
      import ('@/views/positionmanage/index'),
    name: 'positionmanage',
    meta: {
      title: '职位管理',
      icon: 'iconfont iconzhiwei',
      affix: true
    }
  }]
},
{
  path: '/biographical-notes-pool',
  component: Layout,
  children: [{
    path: 'candidate',
    component: () =>
      import ('@/views/biographical-notes-pool/candidate'),
    name: 'candidate',
    meta: { title: '候选人', affix: true }
  },
  {
    path: 'talent-pool',
    component: () =>
      import ('@/views/biographical-notes-pool/talent-pool'),
    name: 'talentPool',
    meta: { title: '人才库', affix: true }
  }
  ],
  meta: {
    title: '简历库',
    icon: 'iconfont iconrencaiku',
    affix: true
  }
},
//  消息
{
  path: '/news',
  component: Layout,
  redirect: '/news/index',
  children: [{
    path: 'index',
    component: () =>
      import ('@/views/news/index'),
    name: 'News',
    meta: {
      title: '消息',
      icon: 'iconfont iconmeirixiaoxituisong',
      noCache: true
    }
  }]
},
{
  path: '/charts',
  component: Layout,
  meta: {
    title: '招聘报表',
    icon: 'iconfont iconbaobiao'
  },
  children: [
    {
      path: 'progress',
      component: () =>
        import ('@/views/charts/progress'),
      name: 'Progress',
      meta: {
        title: '招聘进度分析',
        // icon: 'chart',
        affix: true
      }
    }, {
      path: 'analyse',
      component: () =>
        import ('@/views/charts/analyse'),
      name: 'Analyse',
      meta: {
        title: '招聘环节分析',
        // icon: 'el-icon-s-marketing',
        affix: true
      }
    }]
},
// 设置
{
  path: '/setting',
  component: Layout,
  meta: {
    title: '设置',
    icon: 'iconfont iconSetup'
  },
  children: [
    {
      path: 'company',
      component: () =>
        import ('@/views/setting/company'),
      name: 'company',
      meta: {
        title: '企业主页',
        // icon: 'el-icon-s-marketing',
        affix: true
      }
    },
    {
      path: 'account',
      component: () =>
        import ('@/views/setting/account'),
      name: 'account',
      meta: {
        title: '账户设置',
        // icon: 'el-icon-s-marketing',
        affix: true
      }
    },
    {
      path: 'recruit',
      component: () =>
        import ('@/views/setting/recruit'),
      name: 'recruit',
      meta: {
        title: '招聘设置',
        // icon: 'el-icon-s-marketing',
        affix: true
      }
    }]
},
//企业端不需要
// {
//   path: '/conferenceRoom',
//   component: Layout,
//   children: [{
//     path: 'index',
//     component: () =>
//       import ('@/views/conferenceRoom/index'),
//     name: 'conferenceRoom',
//     meta: {
//       title: '会议室管理',
//       icon: 'iconfont iconzhiwei',
//       affix: true
//     }
//   }]
// },
]

/**
 * asyncRoutes
 * 需要根据用户角色动态加载的路由
 */
export const asyncRoutes = [

]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
